<%--
Created by IntelliJ IDEA.
User: 骆鹏
Date: 2017/7/26
Time: 10:43
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <title><fmt:message code="main.query"/></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" type="text/css" href="/css/main/theme3/fontawesome5.min.css" />
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1" />
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/attachment/attachView.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .head{
            margin-top: 16px;
            height: 33px;
        }
        .head .title{
            margin-left: 22px;
        }
        .head .title img {
            display: none;
        }
        .pagediv table tr td span {
            color: #2f8ae3;
        }

        .head span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 16px;
            color: #333;
            display: inline-block;
            vertical-align: middle;
            margin-top: -6px;
        }

        label select{
            width: 130px;
            padding-left: 10px;
            height: 32px;
        }
        .fl input{
            padding: 0 10px;
            width: 138px;
            border: 1px solid #ccc;

        }

        #export,#allexport,#allsearch,#alldelete{
            margin-left: 10px;
            border: 1px solid #2b7edf;
            color: #ffffff;
            background-color: #2b7edf;
            cursor: pointer;
            height: 28px;
            border-radius: 5px;
            width: 70px;
            height: 28px;
        }
        #export,#allexport{
            background-color: #0cae32;
            border: 1px solid #0cae32;
            color: #ffffff;
        }
        #export:hover,#allexport:hover{
            background-color: #17bb3e;
            border: 1px solid #17bb3e;

        }
        #alldelete{
            border: 1px solid #ef4747;
            color: #ffffff;
            background-color: #ef4747;
        }
        #alldelete:hover{
            border: 1px solid #fe4f4f;
            color: #ffffff;
            background-color: #fe4f4f;
        }
        #allexport{
            width: 100px;
        }
        #allsearch{
            width: 100px;
        }
        #end{
            background: #00a0e9;
            margin-left: 10px;
            padding: 5px 1px;
            border-radius: 4px;
            color: #fff;
            cursor: pointer;
        }
        .Query{
            background: #2b7edf;
            margin-left: 10px;
            padding:4px 1px;
            border-radius: 5px;
            color: #fff;
            cursor: pointer;
            width: 70px;
            height: 28px;
        }
        #allsearch:hover, .Query:hover{
            background-color: #3b8eef;
        }
        #pagediv #pageTbody input[name="checkbox"]{
            display: inline-block;
        }
        .pagediv .page-bottom-outer-layer table td:last-child{
            font-weight: normal;
            overflow: hidden;
            white-space: pre;
            height: 40px;
            padding:4px;
            box-sizing: border-box;
            text-overflow: ellipsis;
            font-size: 11pt;
            text-align: left;
            border-right: 1px solid #ddd;
        }
        .sel {
            width:100%;
            max-height:250px;
            position: absolute;
            top: 100%;
            left: 0;
            overflow: auto;
            background: #fff;
            border:1px solid #e2e3e3;
            display: none;
            z-index: 1;
        }
        .sel li{
            line-height: 24px;
            color: #000;
        }
        #list{
            position: relative;
            width:25px;
            height:32px;
            background: #fff;
            border:1px solid #ccc;
            vertical-align: middle;
            position: absolute;
            right: 0px;
            top: 0px;
            border-radius: 0px 3px 3px 0px;
            border-left:none;
        }
        #list img{
            margin-top: -2px;
            margin-left: 0px;
        }
        .canchoose:hover{
            background: #2b7edf;
            color: #fff;
        }
        .ones{
            list-style-type:disc;
        }
        .pagediv .page-bottom-outer-layer table td:nth-child(4){
            text-overflow:clip!important;
            white-space: normal!important;
        }
        .pagediv .page-bottom-outer-layer table td:nth-child(3){
            text-overflow:clip!important;
            white-space: normal!important;
        }
        .pagediv .page-bottom-outer-layer table td:nth-child(7){
            text-overflow:clip!important;
            white-space: normal!important;
        }
        .pagediv .page-top-inner-layer table tr {
            border-color: #e8f4fc;
        }
        .pagediv .page-top-inner-layer table th{
            font-size:14;
            line-height: 30px;
            background-color: #e8f4fc;
        }
        #pageTbody tr:hover {
            background: #e8f4fc;
        }
        .pagediv .page-bottom-inner-layer table tr {
            border: 0;
        }

        .pagediv .page-bottom-inner-layer table tr td:nth-child(2) >img {
            display: none;
        }

        .pagediv .page-top-inner-layer{
            height:40px;
        }
        .pagediv .page-bottom-outer-layer table td{
            font-size:10pt;
        }
        .pagediv .page-bottom-outer-layer table td:last-child{
            font-size:10pt;
        }
        .operationDiv{
            position: absolute;
            width: 150px;
            border: #ccc 1px solid;
            border-radius: 4px;
            background-color: #ffffff;
            z-index: 99;
        }
        .operation{
            display: block;
            /*width: 100%;*/
            margin-left: 0px !important;
            height: 28px;
            padding-left: 10px;
            background: #fff;
            line-height: 28px;
        }
        .operation:hover{
            background-color: #cae1f7;
            color: #000000;
        }

        .search_box {
            margin: 0 auto;
            height:32px;
            width: 100%;
            padding: 5px 0;
        }
        .search_box .search_item {
            position: relative;
            height: 100%;
        }
        .search_item .search_name {
            width: 120px;
            text-align: right;
            margin-top: 6px;
        }
        .search_item .search_inline {
            width: 160px;
            height: 32px;
            display: inline-block;
            position: relative;
        }
        .search_item .search_inline .search_inline_item {
            width: 100%;
            box-sizing: border-box;
            height: 32px;
        }

        .search_box .fanwei .search_inline_item,
        .search_box .status .search_inline_item,
        .search_box .priority .search_inline_item {
            background-image: url('/img/workflow/work/xiala.png');
            background-repeat: no-repeat;
            background-position: 96%;
            appearance: none;
            -moz-appearance: none;
            -webkit-appearance: none;
        }

        .search_select_dept, .search_select_user {
            cursor: pointer;
        }
        .btn_add_work {
            width: 80px;
            height: 30px;
            margin-left: 10px;
            border: 1px solid #2b7edf;
            background: #2b7edf;
            cursor: pointer;
            border-radius: 6px;
            font-size: 10pt;
            color: #fff;
        }
        .btn_del_work {
            margin-left: 10px;
            width: 80px;
            height: 30px;
            border: 1px solid #ef4747;
            background: #ef4747;
            cursor: pointer;
            border-radius: 6px;
            font-size: 10pt;
            color: #fff;
        }
        .pagediv,.page-bottom-inner-layer {
            scrollbar-width: none;
        }
        .pagediv::-webkit-scrollbar,.page-bottom-inner-layer::-webkit-scrollbar {
            width: 0px;
        }

        .page-top-outer-layer:before {
            content: '';
            display: block;
            width: 100%;
            height: 5px;
            background-color: #2a7ddc;
            border-radius: 3px;
        }

        /*override image to fontawesome pro 5*/
        .queryBtn img,
        #export img,
        #alldelete img,
        #allexport img,
        #allsearch img {
            display: none;
        }

        .queryBtn::before,
        #export::before,
        #alldelete::before,
        #allexport::before,
        #allsearch::before,
        .head .title:before {
            font-family: "Font Awesome 5 Pro";
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            display: inline-block;
            font-style: normal;
            font-variant: normal;
            font-weight: 300;
            line-height: 1;
        }

        .queryBtn::before,
        #export::before,
        #alldelete::before,
        #allexport::before,
        #allsearch::before {
            color: #fff;
        }

        .queryBtn::before {
            content: '\f002';
        }
        #export::before {
            content: '\f093';
        }
        #alldelete::before {
            content: '\f00d';
        }
        #allexport::before {
            content: '\f093';
        }
        #allsearch::before {
            content: '\f002';
        }

        .head .title:before {
            content: '\f865';
            font-size: 16px;
            color: #2b7fe0;
        }
        /*override image to fontawesome pro 5*/

        /*工作查询列表操作按钮模板 复制到需要的页面文件中 开始*/

        .editAndDelete0,
        .editAndDelete1,
        .editAndDelete2,
        .editAndDelete3,
        .editAndDelete4,
        .editAndDelete5 {
            margin-right: 10px;
            margin-bottom: 5px;
            margin-top: 5px;
            font-size: 12px;
            padding: 6px;
            border-radius: 3px;
            background-color: #2b7edf;
            color: #fff !important;
        }

    #pageTbody tr{
        cursor: pointer;
    }
        /*只要修改content值*/
        /*查看：f865
          删除或者回收等：f2ed
          传阅：f5da
          转交：f4c6
          委托：f4c4
          催办：f7e4
          结束：f895
        */


        .editAndDelete0:before {
            content: "\f865";
        }
        .editAndDelete1:before {
            content: "\f04a";
        }
        .editAndDelete2:before {
            content: "\f7e4";
        }
        .editAndDelete3:before {
            content: "\f7e4";
        }
        .editAndDelete4:before {
            content: "\f895";
        }
        .editAndDelete5:before {
            content: "\f2ed";
        }


        .editAndDelete0:before,
        .editAndDelete1:before,
        .editAndDelete2:before,
        .editAndDelete3:before,
        .editAndDelete4:before,
        .editAndDelete5:before {
            font-family: "Font Awesome 5 Pro";
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            display: inline-block;
            font-style: normal;
            font-variant: normal;
            font-weight: 300;
            line-height: 1;
            margin-right: 4px;
        }
        /*工作查询列表操作按钮模板 复制到需要的页面文件中 结束*/
        .pagediv .page-top-inner-layer table thead th:nth-child(5),
        .pagediv .page-top-inner-layer table thead th:nth-child(8),
        .pagediv .page-bottom-inner-layer table tr td:nth-child(5),
        .pagediv .page-bottom-inner-layer table tr td:nth-child(8) {
            text-align: center;
        }
        .editAndDelete0 {
            margin-right: 0 !important;
        }

    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<script>

    var mainLoadIndex = layer.load(2);
    // 自定义流程查询获取flowIdsss
    var FLOW_ID = $.GetRequest().FLOW_ID || '';
    // 判断是否是自定义流程查询的标识
    var IsCustomFlow = FLOW_ID && FLOW_ID != '';

</script>

<body>
<!-- 头部标题 -->
<div class="head">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png" style="margin-bottom: 3px;" width="14px" height="14px"><span class="title_text" style="16px"><fmt:message code="main.query"/></span>
    </div>
</div>

<!-- 搜索区域 -->
<div style="margin: 0 auto;width: 97%; ">
    <!-- 普通流程搜索条件 -->
    <div class="default_search" style="display: none;">
        <div class="search_box">
            <%--流程类型--%>
            <label class="fl search_item" style="position: relative">
                <span class="fl search_name"><fmt:message code="workflow.th.processname"/>：</span>
                <div class="search_inline">
                    <input type="text" class="search_inline_item" name="flowName" placeholder="全部流程" dataType="">
                    <button id="list"><img src="/img/workflow/work/xiala.png" alt=""></button>
                    <ul class="sel"></ul>
                </div>
            </label>
            <%--流水号--%>
            <label class="fl clearfix search_item">
                <span class="fl search_name"><fmt:message code="workflow.th.liushui"/>：</span>
                <div class="search_inline">
                    <input name="runId" class="search_inline_item" placeholder="<fmt:message code="workflow.th.liushui"/>"  type="text" onblur="onblus(this.value);"/>
                </div>
            </label>
            <%--工作名称/文号--%>
            <label class="fl clearfix search_item">
                <span class="fl search_name"><fmt:message code="workflow.th.job"/>：</span>
                <div class="search_inline">
                    <input name="runName" class="search_inline_item" placeholder="<fmt:message code="workflow.th.job"/>"  type="text">
                </div>
            </label>
            <%-- 范围--%>
            <label class="fl clearfix search_item">
                <span class="fl search_name"><fmt:message code="diary.th.Range"/>：</span>
                <div class="search_inline fanwei">
                    <select name="status" class="search_inline_item" id="status">
                        <option value=""><fmt:message code="work.th.AllRange"/></option>
                        <option value="1"><fmt:message code="workflow.th.IStarted"/></option>
                        <option value="2"><fmt:message code="workflow.th.IDidIt"/></option>
                        <option value="5"><fmt:message code="work.th.DesignatedSponsor"/></option>
                        <option value="6"><fmt:message code="work.th.DesignatedController"/></option>
                        <option value="7"><fmt:message code="adding.th.look"/></option>
                    </select>
                    <input  name="userId" type="text" readonly id="userId" user_Id="" style="display: none"/>
                    <a href="javascript:;" id="addUser" style="display: none"><fmt:message code="global.lang.add"/></a>
                    <a href="javascript:;" id="clearUser" style="display: none"><fmt:message code="global.lang.empty"/></a>
                </div>
            </label>


        </div>
        <div class="search_box">
            <%--优先级--%>
            <label class="fl clearfix search_item" style="display:none">
                <span class="fl search_name">紧急程度：</span>
                <div class="search_inline priority">
                    <select name="status2" class="search_inline_item">
                        <option value=""><fmt:message code="notice.th.all"/></option>
                        <option value="0"><fmt:message code="sup.th.ordinary"/></option>
                        <option value="1"><fmt:message code="sup.th.urgent"/></option>
                        <option value="2">特急</option>

                    </select>
                </div>
            </label>
            <%--状态--%>
            <label class="fl clearfix search_item">
                <span class="fl search_name"><fmt:message code="notice.th.state"/>：</span>
                <div class="search_inline status">
                    <select name="status1" class="search_inline_item">
                        <option value=""><fmt:message code="work.th.AllStates"/></option>
                        <option value="1"><fmt:message code="work.th.Executing"/></option>
                        <option value="4"><fmt:message code="work.th.ItOver."/></option>
                    </select>
                </div>
            </label>

            <%--流程发起日期--%>
            <label class="fl clearfix search_item" >
                <span class="fl search_name"><fmt:message code="adding.th.launch"/>：</span>
                <label class="fl">
                    <%--onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"会覆盖掉laydate日期插件判断方法--%>
                    <input  name="beginDate" id="beginDate" placeholder="<fmt:message code="sup.th.startTime"/>"  type="text" readonly="readonly" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>
                    <span style="margin: 0px 50px;">至</span>
                    <%--onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"会覆盖掉laydate日期插件判断方法--%>
                    <input  name="endDate"  id="endDate"  placeholder="<fmt:message code="meet.th.EndTime"/>"  type="text"  readonly="readonly" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>
                </label>
            </label>
        </div>
        <div id="more_div" class="search_box" >


            <div class="fl clearfix" style="margin-left: 65px;margin-bottom: 10px;float: right;">
                <button  type="button" class="Query fl queryBtn">
                    <img src="/img/workflow/worksearch1.png" style="margin-right: -3px;margin-left:-1px;margin-bottom: 4px;" width="11px" height="11px">
                    <span style="margin-left: 3px;"><fmt:message code="global.lang.query"/></span>
                </button>
                <button type="button"  class="export fl" id="export" >
                    <img src="/img/workflow/workdc1.png" style="margin-right: -3px;margin-left:-1px;margin-bottom: 4px;" width="10px" height="10px">
                    <span style="margin-left: 3px;"><fmt:message code="global.lang.report"/></span>
                </button>
                <button type="button"  class="export fl" id="alldelete" onclick="alldelete($(this))">
                    <img src="/img/mywork/deletework2.png" style="margin-right: -3px;margin-left:-1px;margin-bottom: 4px;" width="11px" height="11px">
                    <span style="margin-left: 3px;"><fmt:message code="menuSSetting.th.deleteMenu"/></span>
                </button>
                <button type="button"  class="export fl" id="allexport" >
                    <img src="/img/workflow/workdc1.png" style="margin-right: -3px;margin-left:-1px;margin-bottom: 4px;" width="10px" height="10px">
                    <span style="margin-left: 3px;"><fmt:message code="global.lang.allreport"/></span>
                </button>
                <button type="button"  class="export fl" id="allsearch" onclick="allsearch($(this))">
                    <img src="/img/workflow/worksearch1.png" style="margin-right: -3px;margin-left:-1px;margin-bottom: 2px;" width="11px" height="11px">
                    <span style="margin-left: 3px;"><fmt:message code="global.lang.allsearch"/></span>
                </button>
            </div>
        </div>
    </div>
    <!-- 流程自定义搜索条件 -->
    <div class="custom_search" style="display: none"></div>
</div>

<!-- 页面列表 -->
<div id="pagediv">

</div>
</body>
<script>
    var user_id = '';
    var dept_id = '';
    $(document).keyup(function (e) {//捕获文档对象的按键弹起事件
        if (e.keyCode == 13) {//按键信息对象以参数的形式传递进来了
            //此处编写用户敲回车后的代码
            $('.queryBtn').click();
        }
    });
    function allsearch(){
        window.open('/flowRunPage/allsearch');
    }

    function onblus(x) {
        // 清除两边的空格
        String.prototype.trim = function() {
            return this.replace(/(^\s*)|(\s*$)/g, '');
        };
        var inputStr = x;//用于存放输入的字符串
        if(!inputStr || !inputStr.trim() || isNaN(inputStr)){
            //输入的不是数字
        <%--alert("<fmt:message code="doc.th.number"/>");--%>
        }
    }

    function alldelete(e){
        var deletelayer = layer.load();
        var length = $('.canDelete[name=checkbox]:checked').length;
        var tid = '';
        for(var i=0;i<length;i++){
            var $this = $('.canDelete[name=checkbox]:checked').eq(i);
            var obj = $this.attr('runid');
            tid += obj+',';
        }
        if(tid !=''){
            $.ajax({
                url:"/workflow/work/batchUpdateState?runId="+tid+"&flag=1",
                type:'post',
                dataType:'json',
                success:function(res){
                    $(".queryBtn").click();
                }
            })
        }else{
            layer.close(deletelayer);
            layer.msg('请选择可以删除的流程!',{icon:2});
        }

    }

    $("#addUser").on("click",function(){
        user_id='userId';
        $.popWindow("../common/selectUser?0");
    });
    $("#clearUser").on("click",function(){
        $("#userId").val("");
        $("#userId").attr('user_id','');
    })

    $("#status").change(function () {
        var str=this.value;
        if(str==5 || str==6){
            $('#userId').css("display","inline-block");
            $('#addUser').css("display","inline-block");
            $('#clearUser').css("display","inline-block");
            $('.fanwei').width(382);
            $('#status').css('width','42%');
        }else{
            $('#userId').css("display","none");
            $('#addUser').css("display","none");
            $('#clearUser').css("display","none");
            $('.fanwei').width(160);
            $('#status').css('width','100%');
        }
    })
    $(document).click(function(){
        $('.sel').hide()
    })

    $('#list').click(function(e){
        e.stopPropagation()
        if( $('.sel').css('display')!='none'){
            $('.sel').hide()
        }else{
            $('.sel').show()
        }

    })
    $('[name="flowName"]').keyup(function(){
        $('.sel').show()
        var val=$(this).val()
        $('.sel li').each(function(i,v){
//            console.log(v.innerHTML)
            if(v.innerHTML.indexOf(val)>-1){
                $(v).show();
                $(v).parent().show()
            }else{
                $(v).hide();
            }
        })

    })

    $('.sel').on('click','li',function(e){
        e.stopPropagation()
        if($(this).attr('value')){
            $('[name="flowName"]').val($(this).html())
            $('[name="flowName"]').attr('dataType',$(this).attr('value'))
            $('.sel').hide()
        }else{
            $('.sel').show()
        }
    })

    function buildNode(len,data){
        var prefix = 10;
        for(var i=0;i<len;i++){
            prefix += 10;
        }

        $.each(data,function(i,item){
            if(0 < item.childs.length){
                $('.sel').append("<li style='padding-left:"+(prefix)+"px;font-weight:bold;font-size:14px;' id="+item.sortId +">" + item.sortName + "<li>");
                $.each(item.flowTypeModels,function(j,v){
                    $('.sel').append("<li style='padding-left:"+(prefix+10)+"px;cursor:pointer' class='canchoose' value="+v.flowId +">" +  v.flowName + "<li>");
                })
                buildNode(len+1,item.childs);
            }else{
                $('.sel').append("<li style='padding-left:"+(prefix)+"px;font-weight:bold;font-size:14px;' id="+item.sortId +">" + item.sortName + "<li>");
                $.each(item.flowTypeModels,function(j,v){
                    $('.sel').append("<li style='padding-left:"+(prefix+10)+"px;cursor:pointer' class='canchoose' value="+v.flowId +">" +  v.flowName + "<li>");
                })
            }
        });
    }

    $(function () {
        if (IsCustomFlow) { // 是自定义的流程查询
            $('.default_search').hide()
            $('.custom_search').show()
            // 列表显示的表头
            var tableHead = []
            $.get('/flowRunPage/queryFlowId', {flowId: FLOW_ID}, function(res){
                if (res.flag) {
                    $('.title_text').text(res.object)
                    // 查询条件
                    var searchRequirement = res.datas[0];
                    tableHead = res.datas[1];
                    // 是否允许添加
                    var isAddBtn = res.datas[2]['YN'] === 1;
                    var num = 0;
                    if (searchRequirement.length > 0) {
                        var $searchDiv = $('<div></div>');

                        searchRequirement.forEach(function(search, index){
                            // 每行显示4个查询
                            if (index % 4 === 0) {
                                $searchDiv.append('<div class="search_box"></div>');
                                num++;
                            }
                            var ele = getSearchEle(search);
                            $searchDiv.children().eq(num-1).append(ele);
                        });
                        $('.custom_search').append($searchDiv);
                    }
                    num = num === 0 ? 1 : num;
                    var optSearch = '<button  type="button" class="Query fl queryBtn custom_query">' +
                        '                        <img src="/img/workflow/worksearch1.png" style="margin-right: 2px;margin-left:5px;margin-bottom: 1px;">' +
                        '                        <span style="margin-right: 5px;"><fmt:message code="global.lang.query"/></span>' +
                        '                    </button>';
                    var optAdd = '';
                    var optdel = '<button type="button" class="btn btn-delete btn_del_work" onclick="clickeDelete();"><img src="/img/mywork/deletework1.png" style="margin-right: 7px;margin-bottom: 0px;">删除</button>'
                    if (isAddBtn) {
                        optAdd = '<button type="button" class="btn btn-success btn_add_work" onclick="newWorkFlow();"><img src="/img/mywork/newbuildworjk1.png" style="margin-right: 3px;margin-bottom: 2px;">新建</button>'
                    }

                    $('.custom_search').find('.search_box').eq(num-1).append(optSearch+optAdd+optdel)
                    if (tableHead.length > 0) {
                        pageObj = initTable(tableHead);
                    }
                }
            })

            // 选择部门
            $(document).on('click', '.search_select_dept', function(){
                dept_id = $(this).attr('id');
                $.popWindow("../common/selectDept");
            });

            // 选人员控件
            $(document).on("click", '.search_select_user',function(){
                user_id = $(this).attr('id');
                $.ajax({
                    url:'/imfriends/getIsFriends',
                    type:'get',
                    dataType:'json',
                    data:{},
                    success:function(obj){
                        if(obj.object == 1){
                            $.popWindow("../common/selectUserIMAddGroup");
                        }else{
                            $.popWindow("../common/selectUser");
                        }
                    },
                    error:function(res){
                        $.popWindow("../common/selectUser");
                    }
                })
            });

            // 查询
            $(document).on('click', '.custom_query', function(){
                pageObj = initTable(tableHead);
            });

        } else { // 普通流程查询
            $('.default_search').show()
            $('.custom_search').hide()

            $('#displayBtn').click(function () {
                if($('#more_div').css("display")=="none"){
                    $('#more_div').css("display","block");
                    $("#displayBtn").text("<fmt:message code="main.th.Stop"/>");
                }else {
                    $('#more_div').css("display","none");
                    $('#more_div').css("height","0px");
                    $("#displayBtn").text("<fmt:message code="email.th.more"/>");
                }
            })

            // 获取全部流程
            $.ajax({
                url:"/flow/selOneToAllType",
                type:'post',
                dataType:'json',
                success:function(res){
                    var data=res.datas;
                    var str='<option value=""><fmt:message code="hr.th.PleaseSelect"/></option>';
                    if(res.flag){
                        var flowId = $.GetRequest().flowId;
                        $.each(data,function(i,item){
                            $('.sel').append("<li class='ones' style='font-weight:bold;font-size:14px;' id="+item.sortId +"><img src='../../img/data_points.png' style='margin-right: 5px;' alt=''>" + item.sortName + "<li>");
                            $.each(item.flowTypeModels,function(j,v){
                                $('.sel').append("<li style='padding-left:10px;cursor:pointer' class='canchoose' value="+v.flowId +">" +v.flowName + "<li>");
                                if(flowId&&flowId==v.flowId){
                                    $('[name="flowName"]').val(v.flowName);
                                    $('[name="flowName"]').attr('dataType',v.flowId);
                                    $('[name="flowName"]').attr('readonly','true');
                                    $('#list').hide();
                                    return;
                                }
                            })
                            buildNode(1,item.childs);
                        });
                    }
                }
            });
        }

    });

    function getSearchEle(search){
        var ele = '';
        var htm = '';
        // 搜索名
        var eleName = search[1];
        // 类型
        var dataType = search[0];
        // 字段值
        var searchData = search[2];

        switch (dataType) {
            case 'deptselect': // 部门控件
                htm = '<input class="search_inline_item search_select_dept" placeholder="请选择部门" name="'+searchData+'" id="dept'+searchData+'" readonly autocomplete="off" type="text" />'
                break;
            case 'userselect': // 用户控件
                htm = '<input class="search_inline_item search_select_user" placeholder="请选择用户" name="'+searchData+'" id="dept'+searchData+'" readonly autocomplete="off" type="text" />'
                break;
            case 'calendar': // 日历
            <%--onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"会覆盖掉laydate日期插件判断方法--%>
            htm = '<input style="cursor: pointer" class="search_inline_item" name="'+searchData+'" placeholder="'+eleName+'"  type="text"  readonly="readonly" onclick="laydate({istime: true, format: \'YYYY-MM-DD hh:mm:ss\'})"/>'
                break;
            case 'checkbox': // 复选框
                break;
            case 'radio': // 单选框
                break;
            default:
                htm = '<input class="search_inline_item" name="'+searchData+'" autocomplete="off" type="text" />';
                break;
        }
        ele = '<label class="fl clearfix search_item"><span class="fl search_name">'+eleName+'：</span><div class="search_inline">'+htm+'</div></label>';
        return ele
    }

	

</script>
<script src="/js/workflow/flowRun/flowRun.js?20200904.1"></script>


</html>

